<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 13哥 <yzb321055156@163.com>
// +----------------------------------------------------------------------
namespace app\api\model;
use think\Model;
use app\api\model\UserLikeModel;
use app\api\model\UserFavoriteModel;
class PortalPostModel extends Model
{
    /**
     * 获取评论
     */
    public function getcomments()
    {
        return $this->hasMany('CommentModel', 'object_id', 'id')->field('id,object_id,user_id,parent_id,status,delete_time,content')->where(['delete_time' => 0, 'status' => 1]);
    }

    /**
     * 获取点赞数
     */
    public function getlickcount()
    {
        $res = $this->hasMany('UserLikeModel', 'object_id', 'id')->field('object_id,user_id,id')->where(['type_status' => 1, 'delete_time' => 0]);

        return $res;
    }

    /**
     * 收藏数量
     */
    public function getfavoritecount()
    {
        $res = $this->hasMany('UserFavoriteModel', 'object_id', 'id')->field('object_id,user_id,id')->where(['type_status' => 1, 'delete_time' => 0]);

        return $res;
    }
    /**
     * 关联用户名 （杨正兵）
     */
    public function getuserinfo()
    {
        return $this->hasOne('ImsMemberModel', 'id', 'user_id')->field('id,staff_name,staff_number');
    }

    /**
     * 查看登陆用户收藏状态
     */
    public function getloginuserfavoritestatus($where)
    {

        $UserLikeModel = new UserFavoriteModel();
        return 12222;
    }

    /**
     * 查看登陆用户点赞状态
     */
    public function getloginuserlikestatus($where)
    {
        $UserLikeModel = new UserLikeModel();
        return $UserLikeModel->where($where)->field('id')->find();
    }

}